using System;
using System.Collections.Generic;
using System.Text;


namespace Lizk.SimpleHUD
{
    /*
    public abstract class HUDList : HUDContainerSimple
    {
        protected int displayedIndex = 0;
        protected int animationDirection = 0;
        protected float animationOffset = 0f;
        protected int acceleration = 5, deceleration = 4, currentAcceleration = 0;
        private bool updating = false;


        public event EventHandler AnimationStopped;
        public event EventHandler SelectedIndexChanged;
        public event EventHandler Updated;

        private GUIListContainer list1, list2, currentList;
        protected List<HUDControl> items;


        public bool Updating
        {
            get { return updating; }
            set {
                if (Updated != null && value == false && updating == true)
                    Updated(this, null);
                updating = value; 
            }
        }


        public virtual int SelectedIndex
        {
            get { return currentList.SelectedIndex; }
            set
            {
                if (value < 0)
                    value = 0;

                if (value >= items.Count)
                    value = items.Count - 1;

                SetSelectedIndex(value, true);
            }
        }
        public int Acceleration
        {
            get { return acceleration; }
            set { acceleration = value; }
        }
        public int Deceleration
        {
            get { return deceleration; }
            set { deceleration = value; }
        }
        public bool IsMoving
        {
            get { return animationDirection != 0; }
        }
        public int Direction
        {
            get { return animationDirection; }
        }

        public void SetSelectedIndex(int value, bool animate)
        {
            int h = currentList.SelectedIndex;
            if (!animate)
            {
                displayedIndex = currentList.SelectedIndex = value;
            }
            else
            {
                currentList.SelectedIndex = value;
                if (displayedIndex < currentList.SelectedIndex)
                    animationDirection = 1;
                else if (displayedIndex > currentList.SelectedIndex)
                    animationDirection = -1;
            }
            if (currentList.SelectedIndex != h && SelectedIndexChanged != null && !updating)
                SelectedIndexChanged(this, null);

        }

        public override void Update(TimeSpan ts)
        {
            base.Update(ts);
            UpdateAnimation(ts);
        }

        public void Clear(float fadeSpeed)
        {
            GUIListContainer prev = currentList;
            currentList = currentList == list1 ? list2 : list1;
            prev.Fade(0, fadeSpeed);
            currentList.Fade(255, fadeSpeed);
            items = currentList.Controls;
            items.Clear();
        }

        public new void Clear()
        {
            items.Clear();
        }

        public new int Count
        {
            get { return items.Count; }
        }

        public HUDList()
        {
            items = new List<HUDControl>();
            list1 = new GUIListContainer(items);
            list1.Bounds = Bounds;
            list1.Anchor = Anchor.All;
            Add(list1);
            
            list2 = new GUIListContainer(new List<HUDControl>());
            list2.Bounds = Bounds;
            list2.Anchor = Anchor.All;
            Add(list2);
            
            currentList = list1;
        }

        protected void UpdateAnimation(TimeSpan ts)
        {
            if (animationDirection == 0)
                return;

            // Calculate correct animationDirection
            if (displayedIndex < currentList.SelectedIndex)
                animationDirection = 1;
            else if (displayedIndex == currentList.SelectedIndex)
                animationDirection = animationOffset < 0 ? 1 : -1;
            else if (displayedIndex > currentList.SelectedIndex)
                animationDirection = -1;

            // calculate acceleration
            int diff = Math.Abs(displayedIndex - currentList.SelectedIndex);
            int speed = diff * acceleration;

            if (diff * acceleration > currentAcceleration)
                currentAcceleration = diff * acceleration;
            else if (diff < deceleration)
                if (currentAcceleration / deceleration > acceleration)
                    currentAcceleration = currentAcceleration / deceleration;
                else
                    currentAcceleration = acceleration;

            // set xNext
            animationOffset += (float)ts.TotalSeconds * animationDirection * currentAcceleration;

            int spacesMoved = (int)animationOffset;

            if (Math.Abs(spacesMoved) > 0)
            {
                displayedIndex += spacesMoved > 0 ? 1 : -1;
                animationOffset = 0;
                if (displayedIndex == currentList.SelectedIndex)
                {
                    animationDirection = 0;
                    animationOffset = 0;
                    if (AnimationStopped != null && !updating)
                        AnimationStopped(this, null);
                    return;
                }
            }

            if (displayedIndex == currentList.SelectedIndex && Math.Abs(animationOffset) < ts.TotalSeconds * 10)
            {
                animationOffset = 0;
                animationDirection = 0;
                if (AnimationStopped != null && !updating)
                    AnimationStopped(this, null);
            }




        }
    }

    class ListEnumerator : IEnumerator<HUDControl>
    {
        private int selectedindex, start, end;
        private int currentIndex = -1;
        private List<HUDControl> list;

        public ListEnumerator(List<HUDControl> list, int selectedIndex)
        {
            this.list = list;
            this.selectedindex = selectedIndex;
            start = 0;
            end = list.Count - 1;
        }


        #region IEnumerator<GUIControl> Members

        public HUDControl Current
        {
            get
            {
                if (currentIndex < 0)
                    return null;

                return list[currentIndex];
            }
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
        }

        #endregion

        #region IEnumerator Members

        object System.Collections.IEnumerator.Current
        {
            get
            {
                if (currentIndex < 0)
                    return null;

                return list[currentIndex];
            }
        }

        public bool MoveNext()
        {
            if (list.Count == 0)
                return false;

            if (start < selectedindex)
                currentIndex = start++;
            else if (end > selectedindex)
                currentIndex = end--;
            else
            {
                if (currentIndex == selectedindex)
                    return false;
                currentIndex = selectedindex;
            }
            return true;
        }

        public void Reset()
        {
            currentIndex = -1;
        }

        #endregion
    }

    public class GUIListContainer : HUDContainerSimple
    {
        private int selectedIndex;

        public int SelectedIndex
        {
            get { return selectedIndex; }
            set { selectedIndex = value; }
        }

        public List<HUDControl> Controls { get { return controls; } }

        public GUIListContainer(List<HUDControl> list)
        {
            controls = list;
        }
        
        public new IEnumerator<HUDControl> GetEnumerator()
        {
            return new ListEnumerator(controls, selectedIndex);
        }
    }
*/
}
